package com.example.smartclassroom.controller;

import com.example.smartclassroom.entity.Course;
import com.example.smartclassroom.service.CourseService;
import com.example.smartclassroom.util.JsonDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("course/")
public class CourseController {
    @Autowired
    private CourseService courseService;

    /**
     * 管理员查询所有课程
     * @param course
     * @return
     */
    @GetMapping("queryAllCourse")
    public JsonDate queryAllcourse(Course course) {
        return courseService.queryAllCourse(course);
    }

    /**
     * 管理员新增课程
     * @param course
     * @return
     */
    @PostMapping("addCourse")
    public JsonDate addcourse(@RequestBody Course course) {
        return courseService.addCourse(course);
    }

    /**
     * 删除和批量删除课程
     * @param ids
     * @return
     */
    @RequestMapping("deleteCourse")
    public JsonDate deletecourse(Integer[] ids) {
        return courseService.deleteCourse(ids);
    }

    /**
     * 修改课程
     * @param course
     * @return
     */
    @PostMapping("updateCourseById")
    public JsonDate updateCourseById( Course course) {
        return courseService.updateCourseById(course);
    }


}
